//do not forget to add sqlapi.lib and sqlapi.dll to the project

#include "session.h"
#include <iostream>

using namespace std;
/*
 the following must be done from mysql command line 
	1) enter password qazxcv
	2) create databse on localhost: create database db;
	3) connect to db: connect db;
	4) create user abc with password pass for databse db :
					grant ALL PRIVILEGES ON db to 'abc'@'localhost' identified by 'pass';
	5) when finished drop table employees; drop table managers; drop database db;
*/

int main()
{
	
	//connect to database. create admin account. create employees and managers tables
	Session ses;
	
	//create some employee objects
	Employee employee("johnny", "pwd");
	Employee employee2("johnny", "pass");
	Employee e3("fred pat", "4ire");
	Employee e4("scott gregor", "kgkkg");
	Employee e5("E STONE", "rtyui");
	Employee e6("JOsh GrEEnMan","LoLol");

	//add the employee objects to the database
	ses.addEmployee( employee );
	ses.addEmployee( employee2 );
	ses.addEmployee( e3 );
	ses.addEmployee( e4);
	ses.addEmployee( e5);
	ses.addEmployee( e6);

	//create some manager objects
	Manager manager("manny", "secret");
	Manager m2("bobby brown", "noway");
	
	//add the manager objects to the database
	ses.addManager( manager );
	ses.addManager( m2 );

	//delete an employee and a manager
	ses.deleteEmployee( "johnny" );
	ses.deleteManager( "manny" );

	//change some manager and employee passwords
	ses.changeEmployeePassword("fred pat", "oeoeoe");
	ses.changeManagerPassword("bobby brown", "NEW");
	ses.changeManagerPassword("admin", "HACKED");

	//fetch some data
	cout << ses.getEmployeePassword( "fred pat") << endl;
	cout << ses.getManagerPassword( "bobby brown") << endl;
	cout << endl << endl;

	ses.displayAllUsers();

	//set a availability
	ses.setAvailability("E STONE", "1001011011");
	ses.setAvailability("E STONE", "10101010101010");

	//fetch some data
	cout << endl << ses.getAvailability( "E STONE" ) << endl;

	//
	//login simulation
	//
	/*
	string username, password;
	bool isManager;
	cin >> username;
	cin >> password;
	cin >> isManager;

	if( isManager ){
		if (ses.getManagerPassword( username ) == password){
			//open new window
		}
		else{
			cerr << "bad password" << endl;
		}
	}
	else{
		if( ses.getEmployeePassword( username ) == password ){
			//open new window
		}
		else{
			cerr << "bad password" << endl;
		}
	}
	*/
	cout << endl;
	vector<Employee> allEmployees = ses.getAllEmployees();
	allEmployees[0].incrementShiftCount(); //just testing this method
	for( unsigned int i = 0; i < allEmployees.size(); i++){
		cout << allEmployees[i].getName() << " " << allEmployees[i].getAvailability() << " " << allEmployees[i].getShiftCount() << endl;
	}
	
	return 0;
}